﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Utilities;

namespace DLV.Data.Entities
{
    public class WardController
    {
        public int InsertWard(WardInfo info)
        {
            return SQL.InsertWard(info.DistrictId, info.WardName);
        }
        public void UpdateWard(WardInfo info)
        {
            SQL.UpdateWard(info.WardId, info.DistrictId, info.WardName);
        }
        public void DeleteWard(WardInfo info)
        {
            DeleteWard(info.WardId);
        }
        public void DeleteWard(int wardId)
        {
            SQL.DeleteWard(wardId);
        }
        public WardInfo GetWard(int wardId)
        {
            return CBO.FillObject<WardInfo>(SQL.GetWard(wardId));
        }
        public List<WardInfo> ListWard()
        {
            return CBO.FillCollection<WardInfo>(SQL.ListWard());
        }
        public List<WardInfo> ListWardByDistrict(int districtId)
        {
            return CBO.FillCollection<WardInfo>(SQL.ListWardByDistrict(districtId));
        }
        public DataTable SelectWard()
        {
            return CBO.ConvertToDataTable(ListWard(), typeof(WardInfo));
        }
        public Dictionary<object, object> ListWardLookup()
        {
            var pages = ListWard();
            var dicpages = new Dictionary<object, object>();
            foreach (var info in pages)
                dicpages.Add(info.WardId, info.WardName);
            return dicpages;
        }

    }
}
